ZipFile - How to update an existing zip file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Cook

    #1

    ZipFile - How to update an existing zip file

    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(ro ot,name)
    print "adding ",fp,"...",
    compresstype = zipfile.ZIP_DEF LATED
    if zipfile.is_zipf ile(fp):
    compresstype = zipfile.ZIP_STO RED
    zf.write(fp,com press_type=comp resstype)
    print 'done.'



    Thanks in advance.

    Ian Cook
    (Freeware author of Kirby Alarm And Task Scheduler)

Working...