Where can I suggest an enchantment for Python Zip lib?

Larry Bates larry.bates at websafe.com
Thu Jun 7 14:26:00 EDT 2007


durumdara wrote:
> Hi!
> 
> Where can I ask it?
> 
> I want to ask that developers change the Python's Zip lib in the next
> versions.
> The Zip lib not have a callback procedure. When I zip something, I don't
> know, what is the actual position of the processing, and how many bytes
> remaining.
> It is simply rewriteable, but when I get new Python, it is forget this
> thing again...
> 
> So some callback needed for it, if possible. With this I can abort
> processing and I can show the actual state when I processing a large file.
> 
> See this thread:
> http://groups.google.com.kh/group/comp.lang.python/browse_thread/thread/c6069d12273025bf/18b9b1c286d9af7b?lnk=st&q=python+zip+callback&rnum=1#18b9b1c286d9af7b
> 
> 
> Thanks for your help:
> dd
> 
> 
You can easily find out roughly how many bytes are in your .ZIP archive
by using following:

zipbytes=Zobj.fp.tell()

Where Zobj is your zipfile instance.  You don't need a callback.

Problem is ill defined for a better solution.  You don't know how much
the "next" file will compress.  It may compress a lot, not at all or
in some situations actually grow.  So it is difficult (impossible?) to
know how many bytes are remaining.  I have a rough calculation where
I limit the files to 2Gb, but you must set aside some space for the
table of contents that gets added at the end (whose size you don't
actually know either). So I use:

maxzipbytesupperlimit=int((1L<<31)-(8*(1<<20)))

That is 2Gb-8Mb maximum TOC limit of a zip file.

I look at zipbytes add the uncompressed size of the next file, if it
exceeds maxzipbytesupperlimit, I close the file and move to the next
zip archive.  If it is smaller, I add the file to the archive.

Hope this helps.

-Larry





More information about the Python-list mailing list