Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for iterable input instead of file #5

Merged
merged 1 commit into from
May 10, 2015

Conversation

sebdiem
Copy link

@sebdiem sebdiem commented Mar 18, 2015

I added the support for writing an iterable to the zip archive.

This can be useful when you have a very large file (typically resulting from a large database request). In this case you may want to split your request in several requests (pagination) and write them separately to the archive without creating a huge file in memory or on the disk.

@sebdiem
Copy link
Author

sebdiem commented Apr 3, 2015

Hi, would you have time to consider this pull request please ?

BR

Sébastien

@allanlei
Copy link
Owner

@sebdiem The changes makes example.py fail to run due to the iterable kwargs taking the replacing the positional arg arcname.

I think it would be a more suitable solution to create a zipstream.ZipFile.write_iter(arcname, iter[, compress_type]) method instead of modify write.

  • Keeps the function signature the same as stdlib's zipfile.ZipFile.write(filename[, arcname[, compress_type]])
  • arcname would be a required positional argument instead of kwarg.
  • Let's example.py work again
  • There is a similar method/reference zipfile.ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type])

@sebdiem
Copy link
Author

sebdiem commented Apr 24, 2015

Thanks for your review.
I will update my PR

@sebdiem
Copy link
Author

sebdiem commented Apr 24, 2015

Done!

@allanlei
Copy link
Owner

Can you update your changes to the README? It's still using write(iterable=iterable)

@sebdiem
Copy link
Author

sebdiem commented Apr 28, 2015

Right! I have just updated the README.
In fact I also corrected it because it was referring to an old api (zipstream.ZipFile(path) does not create an archive with files in path)

allanlei added a commit that referenced this pull request May 10, 2015
Added support for iterable input instead of file
@allanlei allanlei merged commit 7342868 into allanlei:master May 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants