ZipFile - How to update an existing zip file

Ian Cook ian at kirbyfooty.com
Thu Nov 18 00:36:43 CET 2004


Hi,
I'm new to python so please excuse me if this is a 'dumb' question.

I want to use the ZipFile module to UPDATE, rather than append, or
create a new zip file.

Does anyone know how this can be done?

This is a snippet of the code I have now..

                try:
                    zf = zipfile.ZipFile(zfname,mode='a')
                except:
                    zf = zipfile.ZipFile(zfname,mode='w')
                    
                for name in cutflist:
                    fp = os.path.join(root,name)
                    print "adding ",fp,"...",
                    compresstype = zipfile.ZIP_DEFLATED
                    if zipfile.is_zipfile(fp):
                        compresstype = zipfile.ZIP_STORED
                    zf.write(fp,compress_type=compresstype)
                    print 'done.'



Thanks in advance.

Ian Cook
(Freeware author of Kirby Alarm And Task Scheduler)
http://www.kirbyfooty.com/



More information about the Python-list mailing list