Skip to content

Commit

Permalink
buffer size @MethodClass
Browse files Browse the repository at this point in the history
  • Loading branch information
sandes committed Mar 26, 2020
1 parent 4c3a9b6 commit e790bd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
name='zipfly',
packages=['zipfly'],
description='ZipFly',
version='1.1.4',
version='1.1.5',
url='http://github.com/buzonIO/zipfly',
download_url = 'https://github.com/BuzonIO/zipfly/archive/v1.1.4.tar.gz',
download_url = 'https://github.com/BuzonIO/zipfly/archive/v1.1.5.tar.gz',
author='Buzon',
author_email='support@buzon.io',
keywords=['zipfly','buzon'],
Expand Down
28 changes: 24 additions & 4 deletions zipfly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from __future__ import unicode_literals, print_function, with_statement

__version__ = '1.1.4'
__version__ = '1.1.5'

from zipfile import (
ZIP_STORED,
Expand Down Expand Up @@ -77,21 +77,38 @@ def get_chunk():
return entry.read(1024 * self.chunksize)

return get_chunk()


def get_size(self):

return self._buffer_size


def buffer_size(self):

# using to get the buffer size
# this size is different from the size of each file added


for i in self.generator(): pass
return self._buffer_size


def generator(self):

"""
@ from_file classemthod of ZipFile->ZipInfo
filename should be the path to a file or directory on the filesystem.
arcname is the name which it will have within the archive (by default,
this will be the same as filename, but without a drive letter and with
leading path separators removed).
"""

stream = Stream()

with ZipFile(stream, mode='w', ) as zf:

for path in self.paths:
for path in self.paths:

z_info = ZipInfo.from_file(path['filesystem'], path['name'])

Expand All @@ -109,4 +126,7 @@ def generator(self):

yield stream.get()
self._buffer_size = stream.size()
stream.close()
stream.close()


# close stream
Binary file added zipfly/__init__.pyc
Binary file not shown.

0 comments on commit e790bd2

Please sign in to comment.