difficult zipefile Question
matthiasjanes
matthiasjanes at gmx.net
Thu Oct 7 02:26:58 EDT 2004
Michael Hoffman <m.h.3.9.1.without.dots.at.cam.ac.uk at example.com> wrote in message news:<ck1tfn$q64$1 at gemini.csx.cam.ac.uk>...
> matthiasjanes wrote:
> > def zipit(path, ziper):
> >
> > for root, dirs, files in os.walk(path):
> >
> > for anyFile in files:
> >
> > fullname = os.path.join(root, anyFile)
>
> Where is the "ziper" variable used? I don't see how this code does
> anything except create an empty zipfile.
>
Sorry I did not post all the code:
#sample code
import os, zipfile, string
def zipit(path, ziper):
for root, dirs, files in os.walk(path):
for anyFile in files:
fullname = os.path.join(root, anyFile)
archiveName = string.lstrip( fullname,path + "\\" )
ziper.write(fullname, archiveName, zipfile.ZIP_DEFLATED )
if __name__ == '__main__':
ziper = zipfile.ZipFile('test.zip', 'w')
zipit('somefolderTozip', ziper)
ziper.close()
#______________________
all seems to work - just empty subfolders are gone.
I checkt it out - 7-zip for instance keps also empty subfolders.
maybe someone has an idea.
thanks MrJanes
More information about the Python-list
mailing list