Ian Ward's email:
first name at this domain
wardi on OFTC, freenode and github
mkzip.py creates zip files from files stored on the web server. It can also calculate the final output size before creating a zip file. It uses no intermediate storage.
mkzip.py is designed to create custom zip files for web sites that let users select multiple files to download at the same time.
Current version is 1.2
The following is an example of a cgi script that outputs a zip file containing two avi files, one mp3, and a static readme file:
#!/usr/bin/python import sys import mkzip files = [ ('bloopers/cat.avi', 'cat - bloopers.avi'), ('bloopers/skiing.avi', 'skiing - bloopers.avi'), ('music/waa-waa.mp3', 'waa-waa.mp3'), (None, 'README', "Files zipped by mkzip!\n"), ] sys.stdout.write( "Content-type: application/x-zip-compressed\r\n" ) sys.stdout.write( "Content-length: %d\r\n\r\n" % mkzip.size_of_zip(files) ) mkzip.create_zip( sys.stdout, files )
The first entry in each of the “files” tuples is the actual file name to be included. The second entry is the name of the file as it will appear in the zip file. If the first entry is
None then the third entry contains the contents of the file as a string.
size_of_zip() calculates the total zip file size by reading the size of the files on disk.
create_zip() generates a zip file without any intermediate files stored on disk.